"""Isothermal equations of gas dynamics"""

# PyHCL imports
from hogs.grids import grid1d as grid
from hogs.solvers.solver import Solver1D
from hogs.solvers.flux.isothermal import IsothermalEquationsLxfFlux
from hogs.solvers.time_step_functions import IETimeStep
from hogs.solvers.primitive_variable_functions import IEPrimitiveVariable

import numpy

# numerical parameters for the problem
a = 1.0

# initialize the grid
g =  grid.Grid1D()
g.initialize(xlow=-2.0, xhigh=2.0, dx=0.01, nb=2, nvar=2)

# create a solver
solver = Solver1D(nvar=2, tf=0.6, grid=g)

# add the flux function
solver.flux_function = IsothermalEquationsLxfFlux(a=a)

# set the grid for the flux function
solver.flux_function.set_grid( solver.grid )

# time step function
solver.time_step_function = IETimeStep(a=a)

# primitive variable function
solver.primitive_variable_function = IEPrimitiveVariable(solver.grid)

# process command line
solver.setup()

grid = solver.grid; q = grid.q; x = grid.xc

for i, j in enumerate(x):
    if j <= 0.0:
        q[0,i] = 1.0

    else:
        q[0,i] = 0.5
    
# solve the system
solver.solve()
